import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:qyou_app/common/base.dart';

class RefreshFooter extends StatelessWidget with Base {
  final bgColor;
  RefreshFooter({this.bgColor});

  @override
  Widget build(BuildContext context) {
    final height = dp(50);
    final textStyle = TextStyle(
      color: Color(0xffA7A7A7),
      fontSize: dp(13),
    );

    return CustomFooter(builder: (BuildContext context, LoadStatus mode) {
      Widget body;
      if (mode == LoadStatus.idle) {
        body = Text(
          "上拉加载～",
          style: textStyle,
        );
      } else if (mode == LoadStatus.loading) {
        //body = CupertinoActivityIndicator();
        //body = LinearProgressIndicator();
        //body = RefreshProgressIndicator();
        body = Container(
          height: dp(20),
          width: dp(20),
          child: CircularProgressIndicator(
            strokeWidth: 3,
            backgroundColor: Base.defaultColor,
            valueColor: new AlwaysStoppedAnimation<Color>(Base.defaultColor),
          ),
        );
      } else if (mode == LoadStatus.failed) {
        body = Text(
          "加载失败～",
          style: textStyle,
        );
      } else if (mode == LoadStatus.canLoading) {
        body = Text(
          "快松手～",
          style: textStyle,
        );
      } else {
        body = Text(
          "我是有底线的～",
          style: textStyle,
        );
      }
      return Container(
        color: bgColor,
        height: height,
        child: Center(
          child: body,
        ),
      );
    });
  }
}
